package com.hengtongxing.hejiayun_employee.pay.wxpay;

import android.app.Activity;

import com.hengtongxing.hejiayun_employee.bean.WXPayDataBean;
import com.hengtongxing.hejiayun_employee.bean.WXPayOrderDataBean;
import com.tencent.mm.opensdk.modelpay.PayReq;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;

/**
 *
 */
public class WXPayUtil {

    public static void pay(Activity activity, WXPayDataBean wxPayBean) {
        IWXAPI api = WXAPIFactory.createWXAPI(activity, wxPayBean.getData().getAppid());
        api.registerApp(wxPayBean.getData().getAppid());
        PayReq req = new PayReq();
        req.appId = wxPayBean.getData().getAppid();//你的微信appid
        req.partnerId = wxPayBean.getData().getPartnerid();//商户号
        req.prepayId = wxPayBean.getData().getPrepayid();//预支付交易会话ID
        req.nonceStr = wxPayBean.getData().getNoncestr();//随机字符串
        req.timeStamp = wxPayBean.getData().getTimestamp();//时间戳
        req.packageValue = wxPayBean.getData().getPackageX();
        req.sign = wxPayBean.getData().getSign();//签名
        api.sendReq(req);
    }

    public static void payV2(Activity activity, WXPayDataBean.DataBean wxPayBean) {
        IWXAPI api = WXAPIFactory.createWXAPI(activity, wxPayBean.getAppid());
        api.registerApp(wxPayBean.getAppid());
        PayReq req = new PayReq();
        req.appId = wxPayBean.getAppid();//你的微信appid
        req.partnerId = wxPayBean.getPartnerid();//商户号
        req.prepayId = wxPayBean.getPrepayid();//预支付交易会话ID
        req.nonceStr = wxPayBean.getNoncestr();//随机字符串
        req.timeStamp = wxPayBean.getTimestamp();//时间戳
        req.packageValue = wxPayBean.getPackageX();
        req.sign = wxPayBean.getSign();//签名
        api.sendReq(req);
    }

    public static void payV3(Activity activity, WXPayOrderDataBean.DataBean.UrlBean wxPayBean) {
        IWXAPI api = WXAPIFactory.createWXAPI(activity, wxPayBean.getAppid());
        api.registerApp(wxPayBean.getAppid());
        PayReq req = new PayReq();
        req.appId = wxPayBean.getAppid();//你的微信appid
        req.partnerId = wxPayBean.getPartnerid();//商户号
        req.prepayId = wxPayBean.getPrepayid();//预支付交易会话ID
        req.nonceStr = wxPayBean.getNoncestr();//随机字符串
        req.timeStamp = wxPayBean.getTimestamp();//时间戳
        req.packageValue = wxPayBean.getPackageX();
        req.sign = wxPayBean.getSign();//签名
        api.sendReq(req);
    }
}
